package br.com.sgc.dao;

import java.util.List;

import javax.ejb.Stateless;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import br.com.sgc.entities.geral.Cliente;
import br.com.sgc.entities.veterinaria.Animal;

@Stateless
public class AnimalDao extends GenericDao<Animal>{

	private static final long serialVersionUID = 2368396000614879999L;

	@SuppressWarnings("unchecked")
	public List<Animal> findAllByCliente(Cliente cliente) {
		Criteria criteria = getCriteria(Animal.class);
		criteria.add(Restrictions.eq("donoAnimal.id", cliente.getId()));
		List<Animal> list = criteria.list();
		for(Animal animal: list){
			animal.getRaca().toString();
			animal.getEspecie().toString();
			animal.getPelagem().toString();
		}
		return list;
	}

	@SuppressWarnings("unchecked")
	public List<Animal> findByHospedagem(Cliente cliente) {
		Criteria criteria = getCriteria(Animal.class);
		criteria.add(Restrictions.eq("hospedado", false));
		criteria.add(Restrictions.eq("donoAnimal.id", cliente.getId()));
		return criteria.list();
	}

}
